package com.health.tablebean.webservice;


import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import com.health.db.FDbManager;

import com.health.model.ManZuFeiFollowupNew;
import com.health.tablebean.CD_DRUGCONDITION;
import com.health.tablebean.PharmacyList;
import com.health.viewscontrols.NovaApplication;

import java.util.ArrayList;
import java.util.List;

/**慢阻肺
 * Created by John on 2019/8/9.
 */
public class ManZuFei {
    /** 编号 */
    private int id;//number
    /** 档案编号 */
    private String archiveid;
    /** 客户姓名 */
    private String customername;
    /** 随访日期 */
    private String followupDate;
    /** 随访医生 */
    private String followupdoctor;
    /** 下次随访日期 */
    private String nextfollowupDate;
    /** 症状（以英文逗号分隔）1无症状2咳嗽咳痰3呼吸困难4胸闷气促5食欲减退6唇指发绀7鼻翼扇动8其他 */
    private String symptom;
    /** 症状：其他 */
    private String symptomother;
    /**身高*/
    private String height;
    /** 体重 */
    private String weight;
    /** 体质指数 */
    private String bmi;

    /**呼吸频率*/
    private String huxipinlv;
    /**脉搏氧饱和度*/
    private String maiboyang;
  /**口唇紫绀*/
    private String kouchunzigan;//1无2有
    /**口唇紫绀 有*/
    private String kouchunziganstr;
    /**下肢肿胀 */
    private String xiazhizhongzhang;// 1 无 2 单侧 3 双侧不对称 4 双侧对
    /** 体症其他 */
    private String physicalsymptomother;
    /**体育锻炼频率*/
    private String tiyuDuanlianpinlv;//1每天2每周一次以上 3偶尔 4不锻炼
    /**体育每次锻炼时间*/
    private String meiciDuanlianTime;
    /**坚持锻炼时间*/
    private String jianchiDuanlianTime;
    /**锻炼方式*/
    private String duanlianfangshi;
    /**吸烟状况*/
    private String xiyanzhuangkuang;//1 从不吸烟 2 已戒烟  3 吸烟
    /**日吸烟量*/
    private String dailysmokenum;
    /**开始吸烟年龄*/
    private String startXiyan;
    /**戒烟年龄*/
    private String endXiyan;
    /**呼吸锻炼频率*/
    private String  huxiDuanlianpinlv;//1每天2每周一次以上 3偶尔 4不锻炼
    /**锻炼时间*/
    private String huxiDuanlianTime;
    /**目标锻炼时间*/
    private String mubiaoDuanlianTime;
    /** 心理调整:1良好 2一般 3差 */
    private String psychoadjustment;
    /** 遵医行为:1良好 2一般 3差 */
    private String obeydoctorbehavior;
    /**辅助检查*/
    private String fuzhujiancha;

    /** 服药依从性:1规律2间断3不服药 */
    private String medicationcompliance;
    /** 药物不良反应:1无 2有 */
    private String adr;
    /** 药物不良反应:有 的值 */
    private String adrEx;
    /** 此次随访分类:1控制满意2控制不满意3不良反应4并发症 */
    private String followuptype;
    /** 随访方式:1门诊 2家庭 3电话 */
    private String followupway;
    /**康复指导与针对性健康教育*/
    private String healthAssess;
    /**	有无转诊*/
    private String isreferral;//有无转诊   DM01-11_2 有 DM01-11_1 无
    /** 转诊：原 因 */
    private String referralreason;
    /** 转诊：机构及科别 */
    private String referralorg;
    /** 创建人 */
    private String createdBy;
    /** 创建时间 */
    private String createdDate;
    /** 修改人 */
    private String lastUpdateBy;
    /** 修改时间 */
    private String lastUpdateDate;
    /**	创建单位 */
    private String createorg;

    /** 修改单位 */
    private String updateorg;
    /**是否上传*/
    private String isUpdate;//Y未上传 N已上传
    /**身份证号*/
    private String idcard;
    /** 创建医生 */
    private String creater;
    /** 修改医生 */
    private String modified;
    /** 诊断*/
    private String diagnosis;

    private String diagnosisstr;
    private String fromType = "2";// 数据来源；空为公卫，‘1’为手提箱，‘2’为PAD

    private List<PharmacyList> pharmacyList;// dosage 用量
    // drugName 药物名称
    // reg2 用药单位
    // usage 用法
    private Rollout rollout;


    public List<PharmacyList> getPharmacyList() {
        return pharmacyList;
    }

    public void setPharmacyList(List<PharmacyList> pharmacyList) {
        this.pharmacyList = pharmacyList;
    }

    public Rollout getRollout() {
        return rollout;
    }

    public void setRollout(Rollout rollout) {
        this.rollout = rollout;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getArchiveid() {
        return archiveid;
    }

    public void setArchiveid(String archiveid) {
        this.archiveid = archiveid;
    }

    public String getCustomername() {
        return customername;
    }

    public void setCustomername(String customername) {
        this.customername = customername;
    }

    public String getFollowupDate() {
        return followupDate;
    }

    public void setFollowupDate(String followupDate) {
        this.followupDate = followupDate;
    }

    public String getFollowupdoctor() {
        return followupdoctor;
    }

    public void setFollowupdoctor(String followupdoctor) {
        this.followupdoctor = followupdoctor;
    }

    public String getNextfollowupDate() {
        return nextfollowupDate;
    }

    public void setNextfollowupDate(String nextfollowupDate) {
        this.nextfollowupDate = nextfollowupDate;
    }

    public String getSymptom() {
        return symptom;
    }

    public void setSymptom(String symptom) {
        this.symptom = symptom;
    }

    public String getSymptomother() {
        return symptomother;
    }

    public void setSymptomother(String symptomother) {
        this.symptomother = symptomother;
    }

    public String getHeight() {
        return height;
    }

    public void setHeight(String height) {
        this.height = height;
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight;
    }

    public String getBmi() {
        return bmi;
    }

    public void setBmi(String bmi) {
        this.bmi = bmi;
    }

    public String getHuxipinlv() {
        return huxipinlv;
    }

    public void setHuxipinlv(String huxipinlv) {
        this.huxipinlv = huxipinlv;
    }

    public String getMaiboyang() {
        return maiboyang;
    }

    public void setMaiboyang(String maiboyang) {
        this.maiboyang = maiboyang;
    }

    public String getKouchunzigan() {
        return kouchunzigan;
    }

    public void setKouchunzigan(String kouchunzigan) {
        this.kouchunzigan = kouchunzigan;
    }

    public String getKouchunziganstr() {
        return kouchunziganstr;
    }

    public void setKouchunziganstr(String kouchunziganstr) {
        this.kouchunziganstr = kouchunziganstr;
    }

    public String getXiazhizhongzhang() {
        return xiazhizhongzhang;
    }

    public void setXiazhizhongzhang(String xiazhizhongzhang) {
        this.xiazhizhongzhang = xiazhizhongzhang;
    }

    public String getPhysicalsymptomother() {
        return physicalsymptomother;
    }

    public void setPhysicalsymptomother(String physicalsymptomother) {
        this.physicalsymptomother = physicalsymptomother;
    }

    public String getTiyuDuanlianpinlv() {
        return tiyuDuanlianpinlv;
    }

    public void setTiyuDuanlianpinlv(String tiyuDuanlianpinlv) {
        this.tiyuDuanlianpinlv = tiyuDuanlianpinlv;
    }

    public String getMeiciDuanlianTime() {
        return meiciDuanlianTime;
    }

    public void setMeiciDuanlianTime(String meiciDuanlianTime) {
        this.meiciDuanlianTime = meiciDuanlianTime;
    }

    public String getJianchiDuanlianTime() {
        return jianchiDuanlianTime;
    }

    public void setJianchiDuanlianTime(String jianchiDuanlianTime) {
        this.jianchiDuanlianTime = jianchiDuanlianTime;
    }

    public String getDuanlianfangshi() {
        return duanlianfangshi;
    }

    public void setDuanlianfangshi(String duanlianfangshi) {
        this.duanlianfangshi = duanlianfangshi;
    }

    public String getXiyanzhuangkuang() {
        return xiyanzhuangkuang;
    }

    public void setXiyanzhuangkuang(String xiyanzhuangkuang) {
        this.xiyanzhuangkuang = xiyanzhuangkuang;
    }

    public String getDailysmokenum() {
        return dailysmokenum;
    }

    public void setDailysmokenum(String dailysmokenum) {
        this.dailysmokenum = dailysmokenum;
    }

    public String getStartXiyan() {
        return startXiyan;
    }

    public void setStartXiyan(String startXiyan) {
        this.startXiyan = startXiyan;
    }

    public String getEndXiyan() {
        return endXiyan;
    }

    public void setEndXiyan(String endXiyan) {
        this.endXiyan = endXiyan;
    }

    public String getHuxiDuanlianpinlv() {
        return huxiDuanlianpinlv;
    }

    public void setHuxiDuanlianpinlv(String huxiDuanlianpinlv) {
        this.huxiDuanlianpinlv = huxiDuanlianpinlv;
    }

    public String getHuxiDuanlianTime() {
        return huxiDuanlianTime;
    }

    public void setHuxiDuanlianTime(String huxiDuanlianTime) {
        this.huxiDuanlianTime = huxiDuanlianTime;
    }

    public String getMubiaoDuanlianTime() {
        return mubiaoDuanlianTime;
    }

    public void setMubiaoDuanlianTime(String mubiaoDuanlianTime) {
        this.mubiaoDuanlianTime = mubiaoDuanlianTime;
    }

    public String getPsychoadjustment() {
        return psychoadjustment;
    }

    public void setPsychoadjustment(String psychoadjustment) {
        this.psychoadjustment = psychoadjustment;
    }

    public String getObeydoctorbehavior() {
        return obeydoctorbehavior;
    }

    public void setObeydoctorbehavior(String obeydoctorbehavior) {
        this.obeydoctorbehavior = obeydoctorbehavior;
    }

    public String getFuzhujiancha() {
        return fuzhujiancha;
    }

    public void setFuzhujiancha(String fuzhujiancha) {
        this.fuzhujiancha = fuzhujiancha;
    }

    public String getMedicationcompliance() {
        return medicationcompliance;
    }

    public void setMedicationcompliance(String medicationcompliance) {
        this.medicationcompliance = medicationcompliance;
    }

    public String getAdr() {
        return adr;
    }

    public void setAdr(String adr) {
        this.adr = adr;
    }

    public String getAdrEx() {
        return adrEx;
    }

    public void setAdrEx(String adrEx) {
        this.adrEx = adrEx;
    }

    public String getFollowuptype() {
        return followuptype;
    }

    public void setFollowuptype(String followuptype) {
        this.followuptype = followuptype;
    }

    public String getFollowupway() {
        return followupway;
    }

    public void setFollowupway(String followupway) {
        this.followupway = followupway;
    }

    public String getHealthAssess() {
        return healthAssess;
    }

    public void setHealthAssess(String healthAssess) {
        this.healthAssess = healthAssess;
    }

    public String getIsreferral() {
        return isreferral;
    }

    public void setIsreferral(String isreferral) {
        this.isreferral = isreferral;
    }

    public String getReferralreason() {
        return referralreason;
    }

    public void setReferralreason(String referralreason) {
        this.referralreason = referralreason;
    }

    public String getReferralorg() {
        return referralorg;
    }

    public void setReferralorg(String referralorg) {
        this.referralorg = referralorg;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public String getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(String createdDate) {
        this.createdDate = createdDate;
    }

    public String getLastUpdateBy() {
        return lastUpdateBy;
    }

    public void setLastUpdateBy(String lastUpdateBy) {
        this.lastUpdateBy = lastUpdateBy;
    }

    public String getLastUpdateDate() {
        return lastUpdateDate;
    }

    public void setLastUpdateDate(String lastUpdateDate) {
        this.lastUpdateDate = lastUpdateDate;
    }

    public String getCreateorg() {
        return createorg;
    }

    public void setCreateorg(String createorg) {
        this.createorg = createorg;
    }

    public String getUpdateorg() {
        return updateorg;
    }

    public void setUpdateorg(String updateorg) {
        this.updateorg = updateorg;
    }

    public String getIsUpdate() {
        return isUpdate;
    }

    public void setIsUpdate(String isUpdate) {
        this.isUpdate = isUpdate;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getModified() {
        return modified;
    }

    public void setModified(String modified) {
        this.modified = modified;
    }

    public String getDiagnosis() {
        return diagnosis;
    }

    public void setDiagnosis(String diagnosis) {
        this.diagnosis = diagnosis;
    }

    public String getDiagnosisstr() {
        return diagnosisstr;
    }

    public void setDiagnosisstr(String diagnosisstr) {
        this.diagnosisstr = diagnosisstr;
    }

    public String getFromType() {
        return fromType;
    }

    public void setFromType(String fromType) {
        this.fromType = fromType;
    }



    public static List<ManZuFei> convertData(Context context) {
        Log.e("慢阻肺上传", NovaApplication.getJgrno());
        List<ManZuFeiFollowupNew> datas = NovaApplication.fdbmanger.findAllByWhere(ManZuFeiFollowupNew.class,"isUpdate is not 'N'"+"and creater='"+NovaApplication.getJgrno()+"'");
        List<ManZuFei> wbdatas = new ArrayList<ManZuFei>();
        ManZuFei wbdata;
        for (ManZuFeiFollowupNew data : datas) {
            wbdata = new ManZuFei();

            wbdata.setAdr(data.getAdr());
            wbdata.setAdrEx(data.getAdrEx());
            wbdata.setArchiveid(data.getArchiveid());
            wbdata.setBmi(data.getBmi());
            wbdata.setCreatedBy(data.getCreatedBy());
            wbdata.setCreatedDate(data.getCreatedDate());
            wbdata.setCreateorg(data.getCreateorg());
            wbdata.setCreater(data.getCreater());
            wbdata.setCustomername(data.getCustomername());
            wbdata.setDailysmokenum(data.getDailysmokenum());
            wbdata.setDiagnosis(data.getDiagnosis());
            wbdata.setDiagnosisstr(data.getDiagnosisstr());
            wbdata.setDuanlianfangshi(data.getDuanlianfangshi());
            wbdata.setEndXiyan(data.getEndXiyan());
            wbdata.setFollowupDate(data.getFollowupDate());
            wbdata.setFollowupdoctor(data.getFollowupdoctor());
            wbdata.setFollowuptype(data.getFollowuptype());
            wbdata.setFollowupway(data.getFollowupway());
            wbdata.setFromType(data.getFromType());
            wbdata.setFuzhujiancha(data.getFuzhujiancha());
            wbdata.setHealthAssess(data.getHealthAssess());
            wbdata.setHeight(data.getHeight());
            wbdata.setHuxiDuanlianpinlv(data.getHuxiDuanlianpinlv());
            wbdata.setHuxiDuanlianTime(data.getHuxiDuanlianTime());
            wbdata.setHuxipinlv(data.getHuxipinlv());
            wbdata.setIdcard(data.getIdcard());
            wbdata.setIsreferral(data.getIsreferral());
            wbdata.setJianchiDuanlianTime(data.getJianchiDuanlianTime());
            wbdata.setKouchunzigan(data.getKouchunzigan());
            wbdata.setKouchunziganstr(data.getKouchunziganstr());
            wbdata.setLastUpdateBy(data.getLastUpdateBy());
            wbdata.setLastUpdateDate(data.getLastUpdateDate());
            wbdata.setMaiboyang(data.getMaiboyang());
            wbdata.setMedicationcompliance(data.getMedicationcompliance());
            wbdata.setMeiciDuanlianTime(data.getMeiciDuanlianTime());
            wbdata.setModified(data.getModified());
            wbdata.setMubiaoDuanlianTime(data.getMubiaoDuanlianTime());
            wbdata.setNextfollowupDate(data.getNextfollowupDate());
            wbdata.setObeydoctorbehavior(data.getObeydoctorbehavior());
            wbdata.setPhysicalsymptomother(data.getPhysicalsymptomother());
            wbdata.setPsychoadjustment(data.getPsychoadjustment());
            wbdata.setReferralorg(data.getReferralorg());
            wbdata.setReferralreason(data.getReferralreason());
            wbdata.setStartXiyan(data.getStartXiyan());
            wbdata.setSymptom(data.getSymptom());
            wbdata.setSymptomother(data.getSymptomother());
            wbdata.setTiyuDuanlianpinlv(data.getTiyuDuanlianpinlv());
            wbdata.setUpdateorg(data.getUpdateorg());
            wbdata.setWeight(data.getWeight());
            wbdata.setXiazhizhongzhang(data.getXiazhizhongzhang());
            wbdata.setXiyanzhuangkuang(data.getXiyanzhuangkuang());


            Rollout rollout = new Rollout();
            rollout.setHpc(data.getReferralreason());
            rollout.setRollInRegion(data.getReferralorg());
            wbdata.setRollout(rollout);


            FDbManager dbm = FDbManager.getInstance(context);
            List<CD_DRUGCONDITION> drs = dbm.findAllByWhere(CD_DRUGCONDITION.class,
                    "IDCARD = '" + data.getIdcard() + "'  AND TYPE = '9'");
            if (drs != null && !drs.isEmpty()) {
                // wbdata.setPharmacyList(pharmacyList
                List<PharmacyList> phs = new ArrayList<>();
                PharmacyList ph = null;
                for (CD_DRUGCONDITION dr : drs) {
                    ph = new PharmacyList();
                    ph.setDosage(dr.getEVERYTIMEMG());
                    ph.setDrugName(dr.getNAME());
                    if (TextUtils.isEmpty(dr.getRES1())) {
                        ph.setReg2("DM04-05_01");// 默认为mg
                    }else{
                        ph.setReg2(dr.getRES1());
                    }
                    ph.setUsage(dr.getDAILYTIME());
                    phs.add(ph);
                }
                wbdata.setPharmacyList(phs);
            } else {
                wbdata.setPharmacyList(new ArrayList());
            }

            wbdatas.add(wbdata);
        }
        return wbdatas;
    }
}
